<template>
  <div>
    <el-row>
      <el-col>
        <div style='position: relative;'>
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="我的关注" name="focusme"><focusme :pageinfome="pageinfome"></focusme></el-tab-pane>
            <el-tab-pane label="已发起关注" name="mefocus"><mefocus :mepageinfo="mepageinfo"></mefocus></el-tab-pane>
          </el-tabs>
          <div style='position: absolute;right:100px;top:-10px;' v-if="activeName=='focusme'">
            <el-row style="width: 800px" >
              <el-col :span="10">
                <el-col :span="1.5">
                  <el-button @click="focusmeall()">
                    全部
                  </el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button @click="focusmeapplystatus(2)">
                    通过
                  </el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button @click="focusmeapplystatus(1)">
                    待审核
                  </el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button @click="focusmeapplystatus(3)">
                    已驳回
                  </el-button>
                </el-col>
              </el-col>

              <el-col :span="10">
                <el-form :inline="true" class="demo-form-inline" style="margin-right: 10px">
                  <el-form-item>
                    <el-input v-model=input placeholder="请输入客户名称、信用代码"></el-input>
                  </el-form-item>
                  <el-form-item>
                    <el-button type="primary" @click="onSubmit1">查询</el-button>
                  </el-form-item>
                </el-form>
              </el-col>
              <el-col :span="2">
                <el-button circle icon="el-icon-refresh" @click="refresh()"></el-button>
              </el-col>
            </el-row>
          </div>
          <div style='position: absolute;right:100px;top:-10px;' v-if="activeName=='mefocus'">
            <el-row style="width: 800px" >
              <el-col :span="10">
                <el-col :span="1.5">
                  <el-button @click="mefocusall()">
                    全部
                  </el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button @click="mefocusapplystatus(2)">
                    关注
                  </el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button @click="mefocusapplystatus(1)">
                    待关注
                  </el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button @click="mefocusapplystatus(3)">
                    已取消
                  </el-button>
                </el-col>
              </el-col>
              <el-col :span="10">
                <el-form :inline="true" class="demo-form-inline" style="margin-right: 10px">
                  <el-form-item>
                    <el-input v-model=input placeholder="请输入客户名称、信用代码"></el-input>
                  </el-form-item>
                  <el-form-item>
                    <el-button type="primary" @click="onSubmit2">查询</el-button>
                  </el-form-item>
                </el-form>
              </el-col>
              <el-col :span="2">
                <el-button circle icon="el-icon-refresh" @click="refresh()"></el-button>
              </el-col>
            </el-row>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import focusme from "./focusme";
import mefocus from "./mefocus";
export default {
  components: {
    focusme,
    mefocus
  },
  data() {
    return {
      activeName: 'focusme',
      input:'',
      pageinfome: {
        pageinfome:{},
        val:''
      },
      mepageinfo:{
        mepageinfo: {},
        val:''
      },
      pn:1,
      page:10,
    };
  },
  methods: {
    handleClick(tab, event) {
      console.log(tab, event);
    },
    onSubmit1() {
      var regex = /^([0-9]{8})[0-9A-Z]{10}$/;
      var regex1 = /^[\u4e00-\u9fa5]+$/;
      if (regex.test(this.input)) {
        this.axios.get(this.baseUrl + "mefocus/queryByCredit/" + this.input)
          .then(res => {
            this.pageinfome.pageinfome.list=[]
            this.pageinfome.pageinfome.list.push(res.data.data);
            this.pageinfome.pageinfome.total=1;

          })
      } else if (regex1.test(this.input)) {
        this.axios.get(this.baseUrl + "mefocus/queryByName/" + this.input)
          .then(res => {
            this.pageinfome.pageinfome.list=[]
            this.pageinfome.pageinfome.list.push(res.data.data);
            this.pageinfome.pageinfome.total=1;
          })
      } else {
        this.$message({
          message: '请输入正确格式的公司名称和信用代码'
        });
      }
      this.input='';
    },
    onSubmit2() {
      var regex = /^([0-9]{8})[0-9A-Z]{10}$/;
      var regex1 = /^[\u4e00-\u9fa5]+$/;
      if (regex.test(this.input)) {
        this.axios.get(this.baseUrl + "mefocus/queryByCredit/" + this.input)
          .then(res => {
            this.mepageinfo.mepageinfo.list=[]
            this.mepageinfo.mepageinfo.list.push(res.data.data);
            this.mepageinfo.mepageinfo.total=1;
          })
      } else if (regex1.test(this.input)) {
        this.axios.get(this.baseUrl + "mefocus/queryByName/" + this.input)
          .then(res => {
            this.mepageinfo.mepageinfo.list=[]
            this.mepageinfo.mepageinfo.list.push(res.data.data);
            this.mepageinfo.mepageinfo.total=1;
          })
      } else {
        this.$message({
          message: '请输入正确格式的公司名称和信用代码'
        });
      }
      this.input='';
    },
    focusmeall(){
      this.axios.get(this.baseUrl + "focusme/findAll/" + this.pn + "/" + this.page)
        .then(res => {
          this.pageinfome.pageinfome = res.data.data
        })
    },
    focusmeapplystatus(val){
      this.axios.get(this.baseUrl + "focusme/findbyapplystatus/"+ val + "/" + this.pn + "/" + this.page)
        .then(res => {
          this.pageinfome.pageinfome = res.data.data
          this.pageinfome.val=val
        })
    },
    mefocusall(){
      this.axios.get(this.baseUrl + "mefocus/findAll/" + this.pn + "/" + this.page)
        .then(res => {
          this.mepageinfo.mepageinfo = res.data.data
        })
    },
    mefocusapplystatus(val){
      this.axios.get(this.baseUrl + "mefocus/findbyapplystatus/"+ val + "/" + this.pn + "/" + this.page)
        .then(res => {
          this.mepageinfo.mepageinfo = res.data.data
          this.mepageinfo.val=val
        })
    },

  },
};
</script>
<style scoped>

</style>
